package cn.iocoder.yudao.adminserver.modules.fi.dal.mysql.project;

import cn.iocoder.yudao.adminserver.modules.fi.controller.project.vo.ProjectExportReqVO;
import cn.iocoder.yudao.adminserver.modules.fi.controller.project.vo.ProjectPageReqVO;
import cn.iocoder.yudao.adminserver.modules.fi.dal.dataobject.project.ProjectDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 项目管理 Mapper
 *
 * @author hickTeam
 */
@Mapper
public interface ProjectMapper extends BaseMapperX<ProjectDO> {

    default PageResult<ProjectDO> selectPage(ProjectPageReqVO reqVO) {
        return selectPage(reqVO, new QueryWrapperX<ProjectDO>()
                .likeIfPresent("project_name", reqVO.getProjectName())
                .eqIfPresent("project_desc", reqVO.getProjectDesc())
                .eqIfPresent("area_manager_uid", reqVO.getAreaManagerUid())
                .eqIfPresent("project_leader_uid", reqVO.getProjectLeaderUid())
                .likeIfPresent("third_name", reqVO.getThirdName())
                .eqIfPresent("director_uid", reqVO.getDirectorUid())
                .eqIfPresent("is_normal", reqVO.getIsNormal())
                .eqIfPresent("is_finish", reqVO.getIsFinish())
                .eqIfPresent("captain_uid", reqVO.getCaptainUid())
                .orderByDesc("update_time")        );
    }

    default List<ProjectDO> selectList(ProjectExportReqVO reqVO) {
        return selectList(new QueryWrapperX<ProjectDO>()
                .eqIfPresent("project_desc", reqVO.getProjectDesc())
                .eqIfPresent("area_manager_uid", reqVO.getAreaManagerUid())
                .eqIfPresent("project_leader_uid", reqVO.getProjectLeaderUid())
                .likeIfPresent("third_name", reqVO.getThirdName())
                .eqIfPresent("director_uid", reqVO.getDirectorUid())
                .eqIfPresent("is_normal", reqVO.getIsNormal())
                .eqIfPresent("is_finish", reqVO.getIsFinish())
                .eqIfPresent("captain_uid", reqVO.getCaptainUid())
                .orderByDesc("update_time")        );
    }
}
